//项目中所有的借口请求都在这里
import instance from './request'

//定义借口请求
//首页
export function getIndexData(params){
    return  instance({
        url:'/index/index',
        method:'get',
        params:params,
    })
}
// 专题页请求
export function getTopicData(params){
    return  instance({
        url:'/topic/list',
        method:'get',
        params:params,
    })
}
//分类页请求
export function getCategoryData(params){
    return  instance({
        url:'/catalog/index',
        method:'get',
        params:params,
    })
}
//当前分类
export function getcurrentCategory(params){
    return  instance({
        url:'/catalog/current',
        method:'get',
        params:params,//get请求 属性名是params
    })
}
//购物车请求
export function getCarData(params){
    return  instance({
        url:'/cart/index',
        method:'get',
        params:params,//get请求 属性名是params
        // headers:{
        //     'X-Nideshop-Token':localStorage.getItem('token')
        // }
    })
}

//我的请求
export function loginFn(params){
    return  instance({
        url:'/auth/loginByWeb',
        method:'post',
        data:params,//post属性名必须是data
        headers:{'content-type':'application/json'}
    })
}

//搜索页
//根据搜索的关键字进行搜索
export function searchgoods(params){
    return  instance({
        url:'/goods/list',
        method:'get',
        params:params,//post属性名必须是data
    })
}

//详情页
export function getDetail(params){
    return  instance({
        url:'/goods/detail',
        method:'get',
        params:params,//post属性名必须是data
    })
}

//详情页相关产品
export function GetGoodsRelatedData(params) {
    return instance({
        url: '/goods/related',
        method: 'get',
        params
    })
}

// 加入购物车
export function addCaeData(params){
    return  instance({
        url:'/cart/add',
        method:'post',
        data:params,//post属性名必须是data
        headers:{'content-type':'application/json'}
    })
}

//获取购物车商品的总数量
export function getGoodsCount(params){
    return  instance({
        url:'/cart/goodscount',
        method:'get',
        params:params,//post属性名必须是data
    })
}
//删除商品
export function carDelete(params){
    return  instance({
        url:'/cart/delete',
        method:'post',
        data:params,//post属性名必须是data
        headers:{'content-type':'application/json'}
    })
}

//类别页 
// 分类数据获取 
export function GetCateGoryData(params) {
    return instance({
        url: '/goods/category',
        method: 'get',
        params:params,
    })
}
// 分类页面商品列表请求
export function GetCateGoryList(params) {
    return instance({
        url: '/goods/list',
        method: 'get',
        params:params,
    })
}

//搜索数据
export function getSearchData(params) {
    return instance({
        url: "/search/index",
        method: 'get',
        params: params,
    })
}

//删除历史搜索
export function clearHistory(data) {
    return instance({
        url: '/search/clearhistory',
        method: 'post',
        data: data,
        headers: { 'content-type': 'application/json' }

    })
}

// 根据搜索的关键字进行搜索
export function searchGoods(params) {
    return instance({
        url: '/goods/list',
        method: 'get',
        params: params,

    })
}